package com.example.demoapp.utils;

public class Event<T> {
    private T data;
    private boolean hasBeenHandled = false;

    private Event(T data){
        this.data = data;
    }

    public static  <T> Event<T> create(T data){
        return new Event<>(data);
    }

    public T getIfNotHandled(){
        if (hasBeenHandled){
            return null;
        }
        hasBeenHandled = true;
        return data;
    }

    public T peekData(){
        return data;
    }
}
